// SPDX-License-Identifier: GPL-2.0
/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2023-2023.
 * Description: ima measure limited
 * Author: zhangguangzhi
 * Create: 2023-11-6
 */

#include <linux/kstrtox.h>
#include <linux/init.h>
#include <linux/printk.h>
#include "ima.h"
#include "ima_measure_limited.h"

int ima_capacity = IMA_DEFAULT_CAPACITY;

static int __init capacity_setup(char *str)
{
	int size, rc;

	rc = kstrtoint(str, 10, &size);
	if (rc < 0) {
		pr_err("invalid measurments capacity!\n");
		return rc;
	}
	if (size < -1) {
		pr_err("measurements capacity should be bigger than -1\n");
		return 1;
	}

	ima_capacity = size;
	if (ima_capacity == -1)
		pr_info("parse infinite measurement capacity\n");
	else
		pr_info("parse measurements capacity: %d\n", ima_capacity);

	return 1;
}
__setup("ima_capacity=", capacity_setup);
